package com.etime.yqtsponsor.controller;

import com.etime.yqtsponsor.common.BaseMessage;
import com.etime.yqtsponsor.common.ListMessage;
import com.etime.yqtsponsor.pojo.ActiveGroup;
import com.etime.yqtsponsor.pojo.ActivePicBank;
import com.etime.yqtsponsor.pojo.ActiveTheme;
import com.etime.yqtsponsor.service.ActivePicBankService;
import com.etime.yqtsponsor.service.ActiveThemeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * @author ly
 * @date 2022/7/22 16:32
 */

@Api(tags = "图片管理的数据接口")
@RestController
@RequestMapping("/active/pic")
public class ActivePicBankController {
    @Autowired
    private ActivePicBankService activePicBankService;

    @Autowired
    private ActiveThemeService activeThemeService;

    @ApiOperation("获取轮播图接口")
    @ApiImplicitParam(name = "id", value = "当前活动id")
    @GetMapping("/get/banner")
//    @Transactional(rollbackFor = {RuntimeException.class, Error.class}, isolation = Isolation.DEFAULT)
    public ListMessage<ActivePicBank> getBannerPics(ActiveTheme activeTheme) {
        ListMessage<ActivePicBank> msg = new ListMessage<>();
        List<ActivePicBank> dataList = activePicBankService.selectBannerPics(activeTheme);
        if(dataList!=null){
            msg.setDatalist(dataList);
            msg.setMsg("获取轮播图成功");
            msg.setCode(1);
        }else {
            msg.setMsg("获取轮播图失败");
            msg.setCode(0);
        }
        return msg;
    }
}
